<template>
	<view class="comp-content">
		<qiun-data-charts 
		      type="map"
		      :opts="state.opts"
		      :chartData="state.chartData"
		    />
	</view>
</template>

<script setup>
	import sheep from '@/sheep';
	import { ygbStaticUrl} from '@/sheep/config';
	import { reactive, computed, onBeforeUnmount,nextTick } from 'vue'
	import qiunDataCharts from '@/pages/user/components/qiun-data-charts/components/qiun-data-charts/qiun-data-charts'
	import { onLoad, onShow, onHide } from '@dcloudio/uni-app';
	const emit = defineEmits(['set'])
	const props = defineProps({
		data:{
			type:Object,
			default:()=>({})
		}
	})
	const state = reactive({
		mapData:[],
		chartData: {},
		opts: {
			color: ["#1890FF"],
			padding: [0,0,0,0],
			dataLabel: true,
			enableScroll: false,
			extra: {
			  map: {
				border: true,
				borderWidth: 1,
				borderColor: "#666666",
				fillOpacity: 0.6,
				activeBorderColor: "#F04864",
				activeFillColor: "#FACC14",
				activeFillOpacity: 1
			  }
			}
		}
	})
	onLoad((opt)=>{
		getServerData()
	})
	function getServerData() {
		return new Promise((resolve,reject)=>{
			uni.request({
			  url: sheep.$url.cdn('/storage/js/china.json',ygbStaticUrl), 
			  method: 'GET',
			  success: (res) => {
				let mapseries = res.data.features.map((item) => {
				  item.color = '#001755';
				  
				  item.borderColor = '#9CFFFF'
				  return item;
				});
				state.chartData = {series:mapseries};
			  },
			  fail: (err) => {
				console.error('请求 JSON 失败:', err);
			  }
			});
		})
	}
	function btnClick(){
		emit('set',{})
		sheep.$router.go('/pages/index/index')
	}
	
</script>

<style lang="scss" scoped>
	.comp-content{
		width: 100%;
		height: 300px;
	}
</style>